package com.qst.controller;

import com.qst.Service.OrderService;
import com.qst.pojo.Order;
import com.qst.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @packageName:com.qst.controller
 * @className:OrderController
 * @Description:
 * @author:zhangyu
 * @date 2021/6/19 18:46
 **/

@Controller
public class OrderController {

    @Resource
    OrderService orderService;

    @RequestMapping(value = "/Allorder")
    public ModelAndView order2(HttpSession session) {
        String selectloginname = (String)session.getAttribute("selectfromloginname");
        List<Order> orders = orderService.findAllOrder(selectloginname);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("orderAll", orders);
        modelAndView.setViewName("Allorder");
        return modelAndView;
    }

    @RequestMapping(value = "/addorder")
    public String addorder(Order order){
        orderService.addorder(order);
        return "redirect:Allorder.do";

    }
    @RequestMapping(value = "/findorder")
    public ModelAndView findorder(String type){
        List<Order> order2 = orderService.Orderbytype(type);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("findorder", order2);
        modelAndView.setViewName("advices");
        return modelAndView;
    }
}
